package com.jdiv.samples.particles;

import com.jdiv.JProcess;

public class Earth extends JProcess{
private int    
	velocity_x; // Bounce length
private int velocity_y;
private int initial_velocity_y;

public Earth(){ 
//	alpha=20;
	}

public void begin(){
	   // Creates process on left middle side
    x=0; y=480;
 //   resolution=10;  // Forces coordinates to use one decimal
    // Initiates horizontal increment from 1 to 8 points
    velocity_x=(int) (Math.random()*7)+1; //rand(10,80);
    // Reinitiates initial bounce length from 8 to 25 points
    initial_velocity_y=-1*((int) (Math.random()*30)+8);//rand(-80,-250);
    // Vertical increment equals bounce length
    velocity_y=initial_velocity_y;
    
   
    
	
}
//Creates an endless loop
public void loop(){
	
	 // Creates a loop that goes over every single image
    // that composes the animation, which ranges from code numbers 0 to 40
    for (graph=1;graph<40;graph++){
    	
        // Moves process horizontally
        x=x+velocity_x;
        // If either side of screen is reached
        if (x<0 || x>640){
            // Changes increment sign, so does
            // with movement direction
            velocity_x=-velocity_x;
        }
        // Moves process vertically
        y=y+velocity_y;
        // If bounce height has reached it's limit
        if (-velocity_y<=initial_velocity_y){
            // Reinitiates length to the initial one
            velocity_y=-velocity_y;
        }else{
            // Decreases increment on bounce length
            velocity_y=velocity_y+2;
        }
        
      
        frame();  // Shows process on screen
    }

}

}
